package com.lkd.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lkd.base.BaseController;
import com.lkd.base.ResponseResult;
import com.lkd.domain.Partner;
import com.lkd.domain.Sku;
import com.lkd.pageParam.PartnerPageParam;
import com.lkd.pageParam.SkuPageParam;
import com.lkd.service.IPartnerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 合作商表 前端控制器
 * </p>
 *
 * @author author
 * @since 2025-02-09
 */
@RestController
@Api("合作商相关接口")
@RequestMapping("/partner")
public class PartnerController extends BaseController {
    @Autowired
    private IPartnerService partnerService;

    @PostMapping
    @ApiOperation("新增合作商")
    public ResponseResult add(@RequestBody Partner partner){
        partnerService.save(partner);
        return success();
    }
    @ApiOperation("合作商搜索")
    @GetMapping
    public ResponseResult<Page<Partner>> search(PartnerPageParam param){
        Page<Partner> page =  partnerService.getPage(param);
        return success(page);
    }
    @ApiOperation("通过id获取合作商详情")
    @GetMapping("/{id}")
    public ResponseResult<Partner> searchById(@PathVariable Long id){
        Partner partner =  partnerService.searchById(id);
        return success(partner);
    }
    @PutMapping
    @ApiOperation("修改合作商")
    public ResponseResult update(@RequestBody Partner partner){
        partnerService.updateById(partner);
        return success();
    }
    @DeleteMapping("/{id}")
    @ApiOperation("根据id删除合作商")
    public ResponseResult deleteById(@PathVariable Long id){
        partnerService.removeById(id);
        return success();
    }
}
